/*
 * @Author: huangtianyang 916072572@qq.com
 * @Date: 2022-12-09 11:27:09
 * @LastEditors: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @LastEditTime: 2024-06-03 10:58:26
 * @FilePath: \driving-training-admin\src\apis\system\protocol.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

import axios from '../../axios/index'

/**
 * 定义协议类型
 */
interface protocolItem {
    value: string
    label: string
}

/**
 * 默认协议
 */
// export const protocolList: protocolItem[] = [
//     {
//         value: 'USER_AGREEMENT',
//         label: '用户协议'
//     },
//     {
//         value: 'PRIVACY_AGREEMENT',
//         label: '隐私协议'
//     }
// ]

/**
 * 定义分页参数接口
 */
interface pageParamsInterface {
    current: number //当前页
    size: number //没有数量
    code?: string //协议code
}

/**
 * 查询协议分页列表
 * @param params
 * @returns
 */
export const getProtocolPage = (params: pageParamsInterface) => {
    return axios({
        method: 'get',
        url: '/api/system/agreement/manage/getPageList',
        params
    })
}

/**
 * 根据协议code获取最新版本号
 * @param code
 * @returns
 */
export const getVersionByCode = (code: string) => {
    return axios({
        method: 'get',
        url: '/api/system/agreement/manage/getLatestVersionCode',
        params: { code }
    })
}

/**
 * 根据id获取协议信息
 * @param id
 * @returns
 */
export const getProtocolInformationById = (id: string) => {
    return axios({
        method: 'get',
        url: '/api/system/agreement/manage/getDetailById',
        params: { id }
    })
}

/**
 * 定义协议状态参数接口
 */
interface StatusInterface {
    id: string
    disable: number //	0.可用；1.禁用
}

/**
 * 修改协议状态
 * @param data
 * @returns
 */
export const changeProtocolStatus = (data: StatusInterface) => {
    return axios({
        method: 'post',
        url: '/api/system/agreement/manage/updateDisable',
        data: data
    })
}

/**
 * 定义添加协议参数接口
 */
interface EditInterface {
    code: string //协议编码
    content: string //协议内容
    name: string //协议标题
    type: string //协议渠道
    version: string //协议版本
}

/**
 * 添加协议
 * @param data
 * @returns
 */
export const editProtocl = (data: EditInterface) => {
    return axios({
        method: 'post',
        url: '/api/system/agreement/manage/add',
        data
    })
}
